package com.example.springboot.demo.controller;

import me.ahoo.cosid.snowflake.SnowflakeId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/snowflake")
public class SnowflakeIdController {


    @Qualifier("__share__SnowflakeId")
    @Lazy
    @Autowired
    private SnowflakeId snowflakeId;

    @GetMapping("/id")
    public Object id2() {
        long id = snowflakeId.generate();
        snowflakeId.stat();
        return id;
    }

    @GetMapping("/stat")
    public Object stat() {
        return snowflakeId.stat();
    }

}
